package cn.hs.controller;

import cn.hs.entity.CourseReply;
import cn.hs.service.CourseReplyService;
import cn.hs.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @ClassName CourseReplyController
 * @Description TODO
 * @Author wsh
 * @Date 2024年10月28日 14:52
 * @Version 1.0
 */
@RestController
@RequestMapping("/courseReply")
public class CourseReplyController {
    @Autowired
    private CourseReplyService courseReplyService;

    @PostMapping("/insert")
    public Result insert(@RequestBody CourseReply courseReply){
        courseReply.setCreateTime(new Date() );
        int num=courseReplyService.insert(courseReply);
        if(num==1){
            return Result.success("添加成功");
        }
        return  Result.error("添加失败");
    }
    @PostMapping("/selectByTalkId")
    public Result selectByTalkId(Integer talkId){
        List<CourseReply> list=courseReplyService.selectByTalkId(talkId);
        Result result=Result.success(list);
        return result;
    }
}
